package com.example.bianpan;

import com.alibaba.fastjson.JSON;
import com.example.bianpan.context.ReviewContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class NodeTask {

    @Autowired
    private  ProcessEngin processEngin;

    public boolean handle()
    {
        double run = processEngin.<ReviewContext,Double>fire("ABILITY_CAL")
                .contextBuilder(()->{
                    ReviewContext context = new ReviewContext();
                    context.setQuantity(1000);
                    return context;
                }).resultBuilder(context ->{
                   Double quantity = context.getQuantity();
                    System.out.println("最终执行结果："+ JSON.toJSONString(context));
                    return quantity;
                }).run();
        if(run<0)
        {
            return  false;
        }
        return  true;
    }
}
